#ifndef LASERCONTROL_AM_H
#define LASERCONTROL_AM_H

#include <QObject>
#include <QString>
#include <QByteArray>
#include <QCoreApplication>
#include <global_defines.h>
#include <QTime>
#include "serialportthread.h"
#include "device_base/lasercontrol_base.h"

class lasercontrol_AM : public LaserControlBase
{
    Q_OBJECT
public:
    explicit lasercontrol_AM(LaserControlBase *parent = nullptr);

    void OpenLaser(const SOFTWARESETTINGS mysetting);
    void OpenLaserProcess(const SOFTWARESETTINGS mysetting);
    void CloseLaser();
    void laserTest(const SOFTWARESETTINGS mysetting);

    void OpenSeedLaser(uint current);
    void SetSeedPumpCurrent(uint current);
    void CloseSeedLaser();
    void CheckSeedCurrent();

    void OpenPulseLaser(uint current);
    void ClosePulseLaser();
    void SetPulsePumpCurrent(uint current);
    void CheckPulseCurrent();

signals:
    void SeedStatusText(QString statusText);
    void PulseStatusText(QString statusText);

public slots:
    void SeedReceiveResp(const QByteArray response);
    void PulseReceiveResp(const QByteArray response);
    void ReadCaseTemperature();
    void ReadDiodeTemperature();
    void emissionStateCheck();//Read the state of emission

private slots:
    void PortError(const QString &s);

private:
    void CheckSeedPumpTemp();
    void OpenCloseSeedPump(bool status);
    void CheckSeedPower();

    void CheckPulsePumpTemp();
    void CheckPulsePumpInputPower();
    void OpenClosePulsePump(bool status);

    void mySleep(unsigned int msec);           //


//    QString SeedLaserPortname;
//    QString PulseLaserPortname;
    QString errorCode;
    int baudRate;
    int waitTimeout, waitForReadyReadTime;
    uint laserSeedCurrent, laserPulseCurrent;
    QString request;
    uint SeedStep, PulseStep, SeedCurrent, PulseCurrent, SeedCurrentSet, PulseCurrentSet;
    uint CheckCount;
    unsigned int waittime;
    bool SeedWorking, PulseWorking, SeedPumpStatus, PulsePumpStatus,istesting,ischecking,isON;

    serialportThread *SeedLaser, *PulseLaser;
    SOFTWARESETTINGS settings;
};

#endif // LASERCONTROL_H
